package com.winning.rabbitmq.simple;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.winning.rabbitmq.ConnectionUtils;
import com.winning.utils.IOUtils;

public class MyProducer {

    private static final String EXCHANGE_NAME = "SIMPLE_EXCHANGE";

    public static void main(String[] args) {

        Connection connection = null;
        Channel channel = null;

        try{
            connection = ConnectionUtils.getConnection();
            channel = connection.createChannel();

            String msg = "Hello RabbitMQ";
            channel.basicPublish(EXCHANGE_NAME, "gupao.best", null, msg.getBytes());
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            IOUtils.close(channel);
            IOUtils.close(connection);
        }


    }

}
